<?php

namespace Modules\Car\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Modules\Car\Entities\RecognizeDrivingLicense;

class MaintainJob //implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //年检
        $car = $this->getStatus('mots_end',2);
        //保险
        $car = $this->getStatus('vci_end',3);
//        交强险
        $car = $this->getStatus('tci_end',5);
        //保养
        $car = $this->getService('last_mileage',4);
    }
    protected function getStatus($continute,$use_status){
        return RecognizeDrivingLicense::query()->where($continute,'<',now()->addMonth(3))->update(['wait_status'=>$use_status]);
    }
    protected function getService($continute,$use_status){
        return RecognizeDrivingLicense::query()->where($continute,'<',1000)->update(['wait_status'=>$use_status]);
    }

}
